package day03.work02;

import java.util.Objects;

public class Person {
    private String name;
    private int age;
    
    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }
    
    // 重写equals方法
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;//判断地址
        if (obj == null || getClass() != obj.getClass()) return false;//判断参数合法性
        Person person = (Person) obj;//类型转换
        return age == person.age && Objects.equals(name, person.name);//比较核心属性
    }
}
